/**
 * Alipay.com Inc. Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.company.exception.base;

/**
 * 异常基类
 *
 * @author poc
 * @version : AbstractBaseException.java, v 0.1 2023年12月15日 16:11:953 poc Exp $
 */
public abstract class AbstractBaseException extends RuntimeException {

    /**
     * 结果码
     */
    private String resultCode;

    /**
     * 业务异常，默认不可重试
     */
    private boolean canRetry = false;

    /**
     * AbstractBaseException
     *
     * @param resultCode  resultCode
     * @param canRetry    canRetry
     * @param placeHolder placeHolder 占位符传的参数列表
     */
    public AbstractBaseException(String resultCode, boolean canRetry, Object... placeHolder) {

        super(MessageUtil.getChineseMessage(resultCode, placeHolder));

        this.resultCode = resultCode;
        this.canRetry = canRetry;
    }

    /**
     * AbstractBaseException
     *
     * @param resultCode  resultCode
     * @param canRetry    canRetry
     * @param placeHolder placeHolder 占位符传的参数列表
     * @param cause       cause
     */
    public AbstractBaseException(String resultCode, boolean canRetry, Throwable cause,
                                 Object... placeHolder) {
        super(MessageUtil.getChineseMessage(resultCode, placeHolder), cause);

        this.resultCode = resultCode;
        this.canRetry = canRetry;
    }

    /**
     * Returns the detail message string of this throwable.
     *
     * @return the detail message string of this {@code Throwable} instance (which may be {@code null}).
     */
    @Override
    public String getMessage() {
        return super.getMessage();
    }

    /**
     * Getter method for property <tt>resultCode</tt>.
     *
     * @return property value of resultCode
     */
    public String getResultCode() {
        return resultCode;
    }

    /**
     * Setter method for property <tt>resultCode</tt>.
     *
     * @param resultCode value to be assigned to property resultCode
     */
    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    /**
     * Getter method for property <tt>canRetry</tt>.
     *
     * @return property value of canRetry
     */
    public boolean isCanRetry() {
        return canRetry;
    }

    /**
     * Setter method for property <tt>canRetry</tt>.
     *
     * @param canRetry value to be assigned to property canRetry
     */
    public void setCanRetry(boolean canRetry) {
        this.canRetry = canRetry;
    }
}